package com.zsp.coupon.convert;


import com.zsp.coupon.constant.DistributeTarget;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;
/**
 * 分发目标枚举属性转换器
 */
@Convert
public class DistributeTargetConvert implements AttributeConverter<DistributeTarget ,Integer> {
    @Override
    public Integer convertToDatabaseColumn(DistributeTarget
                                                       distributeTarget) {
        return distributeTarget.getCode();
    }

    @Override
    public DistributeTarget convertToEntityAttribute(Integer code) {
        return DistributeTarget.of(code);
    }
}
